# 1、创建环境
from pyspark.context import SparkContext

sc = SparkContext(master='local', appName='demo2_map')

# 2、读取数据
students_rdd = sc.textFile("../../data/students.txt")

# 取出班级和年龄
kv_rdd = students_rdd.map(lambda student: (student.split(",")[-1], int(student.split(",")[2])))

# 只对value做处理,key不变
map_values_rdd = kv_rdd.mapValues(lambda age: age + 10)

map_values_rdd.foreach(print)
